(function(angular) {
	'use strict';
	angular.module("fs.waf").constant("Constants", {
		THEME_DEFAULT : 'DEFAULT',
		WELCOME_URL : 'waf.home',
		ENCODE_SEPARATOR : '^',
		CSRF_TOKEN : undefined,
		TRANSACTION_TOKEN : undefined,
		LOGO_URL : 'do/cda/companyImg/logo',
		DEF_XHRHEADERNAME : 'X-Requested-With',
		DEF_XHRHEADERVALUE : 'XMLHttpRequest',
		SESSION_I18N_RESOURES : 'I18N_RESOURCES',
		SESSION_I18N_VALIDATION_RESOURES : 'I18N_VALIDATION_RESOURCES',
		ERROR_CODE_SESSION_TIMEOUT : '302',
		ERROR_CODE_UNAUTHORIZED : '401',
		ERROR_CODE_PAGE_NOT_FOUNT : '404',
		ERROR_CODE_SYSTEM_ERROR : '500',
		ERROR_CODE_CUSTOMER_ERROR : '501',
		NOTIFY_REDIRECT : '302',
		NOTIFY_UNAUTHORIZED : '401',
		NOTIFY_PAGE_NOT_FOUNT : '404',
		NOTIFY_CUSTOMER_ERROR : '501',
		NOTIFY_SYSTEM_ERROR : '500',
		NOTIFY_CHANGE_LANGUAGE : 'change_language',
		NOTIFY_VALIDATION_SUCCESSFUL : 'validation_successful',
		NOTIFY_VALIDATION_FAIL : 'validation_fail',
		TXN_DATATYPES : [
			'PAYMENT-INVOICE-BATCH',
			'SELLER-INVOICE-BATCH',
			'INVOICE-BATCH',
			'PI-DISCOUNT',
			'UPLOAD-PI-BATCH',
			"LOAN",
			"REPAYMENT",
			"DIRECTCHARGE",
			"CUSTPAY"
		]
	}).
	constant("SYS_PARAMS", {
		MULTI_PAGE_SELECT_MAX: 500,
		LOCALE_STATUS : {},
		USER_STATUS : {},
		CCY_CONFIG : {},
		YES_NO : {
			'Y' : 'label.global.yes',
			'1' : 'label.global.yes',
			'N' : 'label.global.no',
			'0' : 'label.global.no'
		},
		REPORT_MODE : {
			'O' : 'label.report.reportmode.online',
			'B' : 'label.report.reportmode.batch',
			'I' : 'label.report.reportmode.inline'
		},
		COMPANY_STATUS : {
			'A' : 'label.company.active',
			'I' : 'label.company.inactive'
		},
		SETUP_STATUS : {
			'C' : 'label.status.c',
			'U' : 'label.status.u',
			'D' : 'label.status.d',
			'J' : 'label.status.j',
			'T' : 'label.status.t',
			'P' : 'label.status.p',
			'G' : 'label.status.g',
			'H' : 'label.status.h',
			'E' : 'label.status.e',
			'V' : 'label.status.v',
			'X' : 'label.status.x',
			'1' : 'label.status.1',
			'2' : 'label.status.2',
			'3' : 'label.status.3',
			'4' : 'label.status.4',
			'5' : 'label.status.5',
			'6' : 'label.status.rp',
			'7' : 'label.status.cu'
		},
		SETUP_STATUS_OPTIONS : {
			"hasEmptyOption": true,
			"data" : [
			    {
					"value" : "V",
					"label" : "label.status.v"
				},{
					"value" : "U",
					"label" : "label.status.u"
				},{
					"value" : "G",
					"label" : "label.status.g"
				},{
					"value" : "T",
					"label" : "label.status.t"
				},{
					"value" : "D",
					"label" : "label.status.d"
				},{
					"value" : "H",
					"label" : "label.status.h"
				}
			]
		},
		LOAN_STATUS : {
			'L' : 'label.loanstatus.entered',
			'D' : 'label.loanstatus.duplicate',
			'N' : 'label.loanstatus.disbursed',
			'P' : 'label.loanstatus.pastdue',
			'X' : 'label.loanstatus.canceled',
			'Q' : 'label.loanstatus.liquated',
			'F' : 'label.loanstatus.closed',
			'R' : 'label.loanstatus.rollovered',
			'C' : 'label.loanstatus.crystalized'
		},
		PENDING_STATUS : {
			'N' : 'label.pendingstatus.notpending',
			'C' : 'label.pendingstatus.pendingforcreditcheck',
			'S' : 'label.pendingstatus.pendingforcustomersetup',
			'R' : 'label.pendingstatus.pendingforreview',
			'B' : 'label.pendingstatus.npl'
		},
		REQ_STATUS : {
			'R' : 'label.extrequest.received',
			'P' : 'label.extrequest.processed',
			'E' : 'label.extrequest.error'
		},
		PAY_TYPE : {
			'C' : 'label.paymdbfile.dda',
			'W' : 'label.paymdbfile.swift',
			'Z' : 'label.paymdbfile.fxcontract'
		},
		INT_COLL_METHOD : {
			'P' : 'label.loan.intcollmethod.prepaid',
			'A' : 'label.loan.intcollmethod.arrears'
		},
		RESPONSE_STATUS:{
			'A' : 'label.incomingrequest.ok',
			'E' : 'label.incomingrequest.rejected',
			'R' : 'label.incomingrequest.error'
		},
		PAYMDB_FILE_STATUS : {
			'C' : 'label.paymdbfile.status.created',
			'S' : 'label.paymdbfile.status.send',
			'K' : 'label.paymdbfile.status.firstreceived',
			'F' : 'label.paymdbfile.status.secondreceived'
		},
		SWIFT_STATUS : {
			'R' : 'label.paymdb.payswiftresponsestatus.myclearmessageisrejected',
			'P' : 'label.paymdb.payswiftresponsestatus.insufficientfund',
			'T' : 'label.paymdb.payswiftresponsestatus.beneficiaryaccountcreditedsuccessfully'
		},
		PAYMDB_STATUS : {
			'A' : 'label.paymdbfile.status.success',
			'R' : 'label.paymdbfile.status.rejected',
			'F' : 'label.paymdbfile.status.failed',
			'X' : 'label.paymdbfile.status.cancelled',
			'T' : 'label.paymdbfile.status.esbtimeout'
		},
		CR_DR : {
			'C' : 'label.global.credit',
			'D' : 'label.global.debit'
		},
		RES_STATUS : {
			'A' : 'label.extresponse.sucess',
			'E' : 'label.extrequest.error'
		},
		NAVIGATION_ACTIONS : {
			'LIST' : 'title.navigation.list',
			'VIEW' : 'title.navigation.view',
			'CREATE' : 'title.navigation.create',
			'CREATECONTINUE' : 'title.navigation.createcontinue',
			'CREATEREJECT' : 'title.navigation.createreject',
			'CREATEVERIFY' : 'title.navigation.createverify',
			'UPDATE' : 'title.navigation.update',
			'UPDATEVERIFY' : 'title.navigation.updateverify',
			'UPDATECONTINUE' : 'title.navigation.updatecontinue',
			'UPDATEREJECT' : 'title.navigation.updatereject',
			'DELETE' : 'title.navigation.delete',
			'DELETEVERIFY' : 'title.navigation.deleteverify',
			'DELETECONTINUE' : 'title.navigation.deletecontinue',
			'DELETEREJECT' : 'title.navigation.deletereject',
			'RESETPASSWORDVERIFY' : 'title.navigation.resetpasswordverify',
			'CHANGEUSERSTATUSVERIFY' : 'title.navigation.changeuserstatusverify',
			'CREATEINITIAL' : 'title.navigation.create',
			'UPLOAD' : 'title.navigation.upload',
			'UPLOADVIEW' : 'title.navigation.uploadview',
			'UPLOADVERIFY' : 'title.navigation.uploadverify',
			'CREATEBUYERVERIFY' : 'title.navigation.createverify',
			'CREATEBANKVERIFY' : 'title.navigation.createverify',
			'CREATEPREVIEWVERIFY' : 'title.navigation.createverify',
			'CREATEPREVIEW' : 'title.navigation.preview',
			'CREATEBANKPREVIEW' : 'title.navigation.preview'
			
		},
		ALL : {
			'*' : 'label.global.all'
		},
		PARM_VALUE_UITYPE : {
			'I' : 'label.dynaparm.parmvaluetype.input',
			'L' : 'label.dynaparm.parmvaluetype.dropdown',
			'D' : 'label.dynaparm.parmvaluetype.dynadropdown',
			'S' : 'label.dynaparm.parmvaluetype.lookup',
			'P' : 'label.dynaparm.parmvaluetype.password'
		},
		SETUP_DYNAPARM_LIST_DATATYPE : {
			'JAVA.LANG.BYTE' : 'parm.type.byte',
			'JAVA.LANG.SHORT' : 'parm.type.short',
			'JAVA.LANG.INTEGER' : 'parm.type.integer',
			'JAVA.LANG.LONG' : 'parm.type.long',
			'JAVA.LANG.CHAR' : 'parm.type.char',
			'JAVA.LANG.FLOAT' : 'parm.type.float',
			'JAVA.LANG.DOUBLE' : 'parm.type.double',
			'JAVA.LANG.STRING' : 'parm.type.string',
			'JAVA.UTIL.DATE' : 'parm.type.date',
			'JAVA.SQL.DATE' : 'parm.type.sqldate',
			'JAVA.SQL.TIMESTAMP' : 'parm.type.timestamp',
			'JAVA.SQL.TIME' : 'parm.type.time',
			'JAVA.MATH.BIGINTEGER' : 'parm.type.biginteger',
			'JAVA.MATH.BIGDECIMAL' : 'parm.type.bigdecimal'
		}
	}).

	config([ 'storageServiceProvider', 'logEnhancerProvider', function(storageServiceProvider, logEnhancerProvider) {
		storageServiceProvider.setLogStorageSize(1000);
		storageServiceProvider.setSearchCriteriaStorageSize(5);
		logEnhancerProvider.logLevels = {
			'*' : logEnhancerProvider.LEVEL.DEBUG
		};

	} ]).

	config([ '$translateProvider', function($translateProvider) {
		$translateProvider.useLoader('i18nLoader');
		/*
		 * escape: escapes HTML in the translation escapeParameters: escapes HTML in the values of the interpolation parameters sanitize: sanitizes
		 * HTML in the translation text using $sanitize sanitizeParameters: sanitizes HTML in the values of the interpolation parameters using
		 * $sanitize
		 */
		$translateProvider.useSanitizeValueStrategy('escapeParameters');
	} ]).

	config([ '$qProvider', function($qProvider) {
		$qProvider.errorOnUnhandledRejections(false);
	} ]).
	
	config([ '$sceProvider', function($sceProvider) {
		$sceProvider.enabled(true);
	} ]).
	
	config([ '$compileProvider', '$httpProvider', 'ajaxServiceFactoryProvider', function($compileProvider, $httpProvider, ajaxServiceFactoryProvider) {
		 //ajaxServiceFactoryProvider.setBaseUrl('');
		 $httpProvider.useApplyAsync(true);
		 $httpProvider.defaults.withCredentials = true;
		 $compileProvider.debugInfoEnabled(true);
	} ]).
	
	config([ 'uibDatepickerPopupConfig', 'uibPaginationConfig', function(datepickerPopupConfig, paginationConfig) {
		datepickerPopupConfig.currentText = 'Biz Date';
		datepickerPopupConfig.clearText = 'Clear';
		datepickerPopupConfig.closeText = 'Close';
		paginationConfig.previousText = 'Previous';
		paginationConfig.nextText = 'Next';
		paginationConfig.firstText = 'First';
		paginationConfig.lastText = 'Last';
	} ]).
	
	config(['$urlRouterProvider', '$locationProvider', 'Constants', 'routerServiceProvider', function($urlRouterProvider, $locationProvider, Constants, routerServiceProvider){
		//$urlRouterProvider.deferIntercept(true);
		$locationProvider.hashPrefix('');
		routerServiceProvider.setTheme(Constants.THEME_DEFAULT);
	} ]).
	
	config([ 'ChartJsProvider', function(ChartJsProvider) {
		ChartJsProvider.setOptions('global', {
			responsive : false
		});
		ChartJsProvider.setOptions('doughnut', {
			cutoutPercentage : 70
		});
		ChartJsProvider.setOptions('global', {
			colors : [ '#00589b', '#018ddd', '#43c13f', '#fb8438', '#dcdcdc', '#f7464a', '#4d5360' ],
			legend : {
				labels : {
					boxWidth : 16,
					padding : 8,
					generateLabels : function(chart) {
						var data = chart.data, legendItems = [];
						if (!angular.isArray(data.datasets)) {
							return legendItems;
						}
						angular.forEach(data.datasets, function(dataset, i) {
							if (!dataset.showInTooltip) {
								legendItems.push({
									text : dataset.label,
									fillStyle : (!angular.isArray(dataset.backgroundColor) ? dataset.backgroundColor : dataset.backgroundColor[0]),
									hidden : !chart.isDatasetVisible(i),
									lineCap : 'square',
									lineDash : dataset.borderDash,
									lineDashOffset : dataset.borderDashOffset,
									lineJoin : dataset.borderJoinStyle,
									lineWidth : dataset.borderWidth,
									strokeStyle : dataset.borderColor,
									pointStyle : dataset.pointStyle,
									datasetIndex : i
								});
							}
						});
						return legendItems;
					}
				}
			},
			tooltips : {
				enabled : true,
				custom : null,
				mode : 'nearest',
				position : 'average',
				intersect : true,
				backgroundColor : 'rgba(0,0,0,0.7)',
				titleFontStyle : 'bold',
				titleFontSize : 8,
				titleSpacing : 6,
				titleMarginBottom : 6,
				titleFontColor : 'rgba(255,255,255,0.7)',
				titleAlign : 'left',
				bodyFontStyle : 'bold',
				bodyFontSize : 10,
				bodySpacing : 6,
				bodyFontColor : '#fff',
				bodyAlign : 'left',
				footerFontStyle : 'bold',
				footerFontSize : 10,
				footerSpacing : 6,
				footerMarginTop : 6,
				footerFontColor : '#fff',
				footerAlign : 'left',
				yPadding : 6,
				xPadding : 6,
				caretPadding : 6,
				caretSize : 5,
				cornerRadius : 6,
				multiKeyBackground : '#fff',
				displayColors : true,
				borderColor : 'rgba(0,0,0,0.7)',
				borderWidth : 0
			}
		});
		ChartJsProvider.setOptions('bar', {
			scales : {
				xAxes : [ {
					categoryPercentage : 0.6,
					barPercentage : 0.7,
				} ]
			}
		});
		ChartJsProvider.setOptions('horizontalBar', {
			scales : {
				xAxes : [ {
					categoryPercentage : 0.6,
					barPercentage : 0.7,
				} ]
			}
		});
	} ]);
	
})(angular);
